package com.alm.token.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import com.alm.token.R;

/**
 * Created by Nelson on 15/11/14.
 */
public class HomeGridLayout extends LinearLayout implements View.OnClickListener {


    public HomeGridLayout(Context context) {
        super(context);
    }

    public HomeGridLayout(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        initView(attributeSet, context);
    }

    public HomeGridLayout(Context context, AttributeSet attributeSet, int defStyle) {
        super(context, attributeSet, defStyle);
        initView(attributeSet, context);
    }

    private void initView(AttributeSet attributeSet, Context context) {
        View view = LayoutInflater.from(getContext()).inflate(R.layout.layout_home_grid, this);
        view.findViewById(R.id.tab1).setOnClickListener(this);
        view.findViewById(R.id.tab2).setOnClickListener(this);
        view.findViewById(R.id.tab3).setOnClickListener(this);
        view.findViewById(R.id.tab4).setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        if (btnInterface != null) {
            btnInterface.onTab(view);
        }

    }

    BtnInterface btnInterface;

    public BtnInterface getBtnInterface() {
        return btnInterface;
    }

    public void setBtnInterface(BtnInterface btnInterface) {
        this.btnInterface = btnInterface;
    }

    public interface BtnInterface {
        void onTab(View view);
    }


}
